home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 610 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: imaginet.fr!usenet
  2. From: Serge Paccalin <paccalin@alpes-net.fr>
  3. Newsgroups: comp.lang.c,alt.msdos.programmer
  4. Subject: Re: Two strange C problems.
  5. Date: Sun, 07 Jan 1996 22:10:41 +0100
  6. Organization: Alpes Networks, Grenoble [Fra]
  7. Message-ID: <30F036D1.2C3C@alpes-net.fr>
  8. References: <4cojb2$qog@lugb.latrobe.edu.au>
  9. NNTP-Posting-Host: alpnet51.alpes-net.fr
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b4 (Win95; I)
  14.  
  15. Gregary John Boyles wrote:
  16. > I have two C problems.
  17. > ...
  18. > PROBLEM 2 :
  19. > const escape=27;
  20. > ... 
  21. > If I replace the 27 with \27' or the 13 with '\13' then these loops don't
  22. > work i.e. an infinite loop results. WHY?
  23.  
  24. I cannot tell for PROBLEM 1 but PROBLEM 2 is easy.
  25. When you write '\27' you are using octal, not decimal; in other words,
  26. '\27' is character 2 * 8 + 7 = 23 (decimal).
  27. If you wish to represent ESCAPE with its value as a char you must use
  28. either hexadecimal '\x1b' or octal '\33'.
  29. There is no way to put a decimal code within quotes but you could also
  30. use a type cast: const escape=(char)27; should do.
  31.  
  32. Best regards
  33. --end of message--
  34.